package com.yoda.controller;


import com.yoda.result.Result;
import com.yoda.service.IYddTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoda.dto.TagDto;
import com.yoda.dto.TagPageQuery;
import com.yoda.result.Result;
import com.yoda.service.IYddTagService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author itcast
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/ydd_tag")
public class YddTagController {


    @Autowired
    private IYddTagService iYddTagService;

    /**
     * 新增标签
     * @return
     */
    @PostMapping("/add")
    @ApiOperation(value = "新增标签")
    public Result addLabel(@RequestBody TagPageQuery dto){
        return iYddTagService.addLabel(dto);
    }

    /**
     * 修改标签
     * @param dto
     * @return
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改标签")
    public Result updateLabel(@RequestBody TagDto dto){
        return iYddTagService.updateLabel(dto);
    }

    /**
     * 查询全部标签
     * @return
     */


    /**
     * 标签列表分页查询
     * @param dto
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "标签列表分页查询")
    public Result page(TagPageQuery dto){
        return iYddTagService.page(dto);
    }

    /**
     * 根据id查询标签
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    @ApiOperation(value = "根据id查询标签")
    public Result getById(Integer id){
        return iYddTagService.getById(id);
    }

    /**
     * 根据ID删除标签
     * @return
     */
    @GetMapping("/del")
    @ApiOperation(value = "根据ID删除标签")
    public Result delById(Integer id){
        return iYddTagService.delById(id);
    }


    /**
     * 查询所有标签
     * @return
     */
    @GetMapping("/all")
    public Result selectAll(){
        return iYddTagService.selectAll();
    }

}

